package com.budweiser.user.dao;

import com.budweiser.model.dict.Dict;
import com.budweiser.user.dto.DictSelectTree;
import com.budweiser.user.dto.DictTree;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DictDao {
	/***
	 * 新增
	 * 
	 * @param dict
	 */
	public void insert(Dict dict);

	/***
	 * 根据Dict构建树形
	 * 
	 * @return
	 */
	public List<DictTree> findDictTree();

	/**
	 * 根据条件查询总条数
	 * 
	 * @param params
	 * @return
	 */
	public int count(Map<String, Object> params);

	/***
	 * 根据params分页查询
	 * 
	 * @param params
	 * @return
	 */
	public List<Dict> findData(Map<String, Object> params);

	public List<DictSelectTree> getSelectDictTree();

	/***
	 * 根据code查询字典对象
	 * 
	 * @param code
	 * @return
	 */
	@Select("select * from sys_dict where deleteStatus = 0 and code = #{code}")
	public Dict getDictByCode(String code);

	public void update(Dict dict);

	@Select("select * from sys_dict where deleteStatus = 0 and code = #{code} and id =#{id}")
	public Dict getDictByIdAndCode(@Param("id") Long id, @Param("code") String code);

	/***
	 * 批量修改删除字段属性为true
	 * 
	 * @param idList
	 */
	public void updateDeleteStatus(List<Long> idList);

	/***
	 * 根据父类code查询Dict集合对象
	 * 
	 * @param code
	 * @return
	 */
	public List<Dict> findDictByParentCode(String code);
	/****
	 * 根據id查詢
	 * @param id
	 * @return
	 */
	@Select("select * from sys_dict where deleteStatus = 0 and id =#{id}")
	public Dict getDictByid(Long id);
}
